/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package radio.entities;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToOne;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author Huu Vinh
 */
@Entity
@Table(name = "Advertise", catalog = "Radio_Cabs", schema = "dbo")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Advertise.findAll", query = "SELECT a FROM Advertise a"),
    @NamedQuery(name = "Advertise.findByAdvertiseId", query = "SELECT a FROM Advertise a WHERE a.advertiseId = :advertiseId"),
    @NamedQuery(name = "Advertise.findByCompanyName", query = "SELECT a FROM Advertise a WHERE a.companyName = :companyName"),
    @NamedQuery(name = "Advertise.findByDesignation", query = "SELECT a FROM Advertise a WHERE a.designation = :designation"),
    @NamedQuery(name = "Advertise.findByFax", query = "SELECT a FROM Advertise a WHERE a.fax = :fax"),
    @NamedQuery(name = "Advertise.findByDescription", query = "SELECT a FROM Advertise a WHERE a.description = :description")})
public class Advertise implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "AdvertiseId", nullable = false)
    private Integer advertiseId;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "CompanyName", nullable = false, length = 30)
    private String companyName;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "Designation", nullable = false, length = 2147483647)
    private String designation;
    // @Pattern(regexp="^\\(?(\\d{3})\\)?[- ]?(\\d{3})[- ]?(\\d{4})$", message="Invalid phone/fax format, should be as xxx-xxx-xxxx")//if the field contains phone or fax number consider using this annotation to enforce field validation
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "Fax", nullable = false, length = 20)
    private String fax;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "Description", nullable = false, length = 2147483647)
    private String description;
    @JoinColumn(name = "AdvertiseTypeId", referencedColumnName = "AdvertiseTypeId", nullable = false)
    @ManyToOne(optional = false)
    private AdvertiseType advertiseTypeId;
    @JoinColumn(name = "AdvertiseId", referencedColumnName = "AccId", nullable = false, insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Accounts accounts;

    public Advertise() {
    }

    public Advertise(Integer advertiseId) {
        this.advertiseId = advertiseId;
    }

    public Advertise(Integer advertiseId, String companyName, String designation, String fax, String description) {
        this.advertiseId = advertiseId;
        this.companyName = companyName;
        this.designation = designation;
        this.fax = fax;
        this.description = description;
    }

    public Integer getAdvertiseId() {
        return advertiseId;
    }

    public void setAdvertiseId(Integer advertiseId) {
        this.advertiseId = advertiseId;
    }

    public String getCompanyName() {
        return companyName;
    }

    public void setCompanyName(String companyName) {
        this.companyName = companyName;
    }

    public String getDesignation() {
        return designation;
    }

    public void setDesignation(String designation) {
        this.designation = designation;
    }

    public String getFax() {
        return fax;
    }

    public void setFax(String fax) {
        this.fax = fax;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public AdvertiseType getAdvertiseTypeId() {
        return advertiseTypeId;
    }

    public void setAdvertiseTypeId(AdvertiseType advertiseTypeId) {
        this.advertiseTypeId = advertiseTypeId;
    }

    public Accounts getAccounts() {
        return accounts;
    }

    public void setAccounts(Accounts accounts) {
        this.accounts = accounts;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (advertiseId != null ? advertiseId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Advertise)) {
            return false;
        }
        Advertise other = (Advertise) object;
        if ((this.advertiseId == null && other.advertiseId != null) || (this.advertiseId != null && !this.advertiseId.equals(other.advertiseId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "radio.entities.Advertise[ advertiseId=" + advertiseId + " ]";
    }
    
}
